﻿using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using CID.Domain.Development;
using CID.Domain.Operations;
using CID.Execution.Support.Information;

namespace CID.Execution.Support.Scripting
{
    [DataContract]
    public class DeactivationScriptStep : ScriptStep
    {
        internal DeactivationScriptStep() : base() { }

        public DeactivationScriptStep(IComponent component, IEnvironment targetEnvironment) :
            base(component.ActivationDeactivationDefinition.DeactivationTemplate, component.ActivationDeactivationDefinition.GetDeactivationParamaterValues(targetEnvironment))
        {
            Component = new ComponentInfo(component);
        }

        [DataMember]
        public ComponentInfo Component { get; set; }

        public DeactivationScriptStep Clone()
        {
            return new DeactivationScriptStep() { Component = Component.Clone(), Template = Template.Clone(), ParameterValues = ParameterValues.Select(x => x.Clone()).ToArray() };
        }
    }
}
